# -*- coding:utf8 -*-

from scrapy import Item, Field

__all__ = ["BaseItem"]


class BaseItem(Item):
    """
    including common items
    """
    # _id = Field()
    # name_first = Field()
    # name_second = Field()
    #
    # uptime = Field()
    # do_time = Field()
    # url = Field()
    #
    # version = Field()
    # rowkey = Field()
    _dup_str = Field()
    result_data = Field()

    def process_item(self, *args, **kwargs):
        """
            process item to dict value for saving
        Args:
            *args:
            **kwargs:
        Returns:
            dict value
        """
        item_dict = dict(self)
        _parsed_data = item_dict.pop('result_data', {})
        item_dict.update(_parsed_data)
        # item_dict['_uptime'] = item_dict['uptime']
        # item_dict['_dotime'] = item_dict['do_time']
        # item_dict['_version'] = item_dict['version']

        return {'_data': item_dict, '_data_type': 0}
